#include "Tracker.h"
#include "getAmmo_cv.h"
#include <global.h>
#include "DataStruct.h"

using namespace std;
using namespace cv;

int detectArmor(Mat &frame, DataStruct &send_data,Tracker &akaze_tracker,char &mode,char &tmp_mode)
{
		send_data.Flag=0;
		cout << "\r\n----------------------------------" << endl;
		//frame=img(Rect());
		if(mode==3||mode==4||mode==5)//mode=3是42,4是17，5是17-42  外面这个if似乎不需要
		{
			if(tmp_mode!=mode) 
			{
				akaze_tracker.setFirstFrame(mode);
				tmp_mode=mode;
			}
		}
		Mat homography = akaze_tracker.process(frame);

		if (homography.empty())
		{
			 return 0;
		}
		vector<Point2f> new_center;
		perspectiveTransform(center, new_center, homography);
		short x = doubleToShort(new_center[0].x - 320.0d);
		
		cout<< "\r\nx:\t" << x/3 << endl;
		send_data.Flag=2;
		send_data.X= x;
		send_data.end= 0x5A;
		return 1;
}
